From fdc97c9ca9eeaa59d44ddf194e9dc56673ec7699 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 5 Sep 2014 10:18:40 -0700 Subject: [PATCH] Remove an outdated module Closes #512 --- src/cargo/core/errors.rs | 122 --------------------------------------- src/cargo/core/mod.rs | 1 - 2 files changed, 123 deletions(-) delete mode 100644 src/cargo/core/errors.rs diff --git a/src/cargo/core/errors.rs b/src/cargo/core/errors.rs deleted file mode 100644 index 33dd5bbe2..000000000 --- a/src/cargo/core/errors.rs +++ /dev/null @@ -1,122 +0,0 @@ -use std::fmt::{mod, Show, Formatter}; -use std::io::IoError; - -/* - * Deprecated and will be phased out. Use util::result instead - */ - -pub type CargoResult = Result; -pub type CLIResult = Result; - -pub enum CargoError { - CargoInternalError(InternalError), - CargoCLIError(CLIError) -} - -impl Show for CargoError { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - match self { - &CargoInternalError(ref err) => write!(f, "{}", err), - &CargoCLIError(ref err) => write!(f, "{}", err) - } - } -} - -pub struct CLIError { - pub msg: String, - pub detail: Option, - pub exit_code: uint -} - -impl CLIError { - pub fn new(msg: T, detail: Option, - exit_code: uint) -> CLIError { - let detail = detail.map(|d| d.to_string()); - CLIError { msg: msg.to_string(), detail: detail, exit_code: exit_code } - } -} - -impl Show for CLIError { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - write!(f, "{}", self.msg) - } -} - -pub enum InternalError { - StringConversionError(String, &'static str), - MissingManifest(Path, String), - WrappedIoError(IoError), - PathError(String), - Described(String), - Other -} - -impl Show for InternalError { - fn fmt(&self, f: &mut Formatter) -> fmt::Result { - match self { - &StringConversionError(ref string, ref type_name) => { - write!(f, "Couldn't convert `{}` into {}", string, type_name) - }, - &MissingManifest(ref path, ref file) => { - write!(f, "Couldn't find a {} in the project (`{}` or any \ - parent directory", file, path.display()) - }, - &WrappedIoError(ref io_error) => { - write!(f, "{}", io_error) - }, - &PathError(ref s) | &Described(ref s) => { - write!(f, "{}", s) - }, - &Other => write!(f, "Other internal error") - } - } -} - -impl CargoError { - pub fn cli(msg: String, detail: Option, - exit_code: uint) -> CargoError { - CargoCLIError(CLIError::new(msg, detail, exit_code)) - } - - pub fn internal(error: InternalError) -> CargoError { - CargoInternalError(error) - } - - pub fn described(description: T) -> CargoError { - CargoInternalError(Described(description.to_string())) - } - - pub fn other() -> CargoError { - CargoInternalError(Other) - } - - pub fn cli_error(self) -> CLIError { - match self { - CargoInternalError(err) => - CLIError::new("An unexpected error occurred", Some(err), 100), - CargoCLIError(err) => err - } - } -} - -pub trait ToResult { - fn to_result(self, callback: |E1| -> E2) -> Result; -} - -impl ToResult for Result { - fn to_result(self, callback: |E1| -> E2) -> Result { - match self { - Ok(val) => Ok(val), - Err(e) => Err(callback(e)) - } - } -} - -impl ToResult,E> for Option { - fn to_result(self, callback: |Option| -> E) -> Result { - match self { - Some(val) => Ok(val), - None => Err(callback(self)) - } - } -} diff --git a/src/cargo/core/mod.rs b/src/cargo/core/mod.rs index 6f6305507..448515579 100644 --- a/src/cargo/core/mod.rs +++ b/src/cargo/core/mod.rs @@ -45,7 +45,6 @@ pub use self::dependency::{ pub use self::version_req::VersionReq; pub use self::resolver::Resolve; -pub mod errors; pub mod source; pub mod package; pub mod package_id; -- 2.30.2